package com.tedu.pj.sys.controller;

import com.tedu.pj.common.pojo.Response;
import com.tedu.pj.sys.pojo.SysRole;
import com.tedu.pj.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/19
 */
@RestController
@RequestMapping("/role/")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @RequestMapping("doFindPageObjects")
    public Response doFindPageObjects(String name, Integer pageCurrent) {
        return new Response(sysRoleService.findPageObjects(name, pageCurrent));
    }

    @RequestMapping("doDeleteObject")
    public Response doDeleteObject(Integer id) {
        sysRoleService.deleteObject(id);
        return new Response("delete ok");
    }

    @RequestMapping("doSaveObject")
    public Response doSaveObject(SysRole entity, Integer[] menuIds) {
        sysRoleService.saveObject(entity, menuIds);
        return new Response("save ok");
    }

    @RequestMapping("doFindObjectById")
    public Response doFindObjectById(Integer id) {
        return new Response(sysRoleService.findObjectById(id));
    }

    @RequestMapping("doUpdateObject")
    public Response doUpdateObject(SysRole entity,Integer[] menuIds) {
        sysRoleService.updateObject(entity, menuIds);
        return new Response("update ok");
    }

    @RequestMapping( "doFindRoles" )
    public Response doFindRoles() {
        return new Response( sysRoleService .findObjects());
    }
}
